package my;



import net.egork.io.IOUtils;
import net.egork.io.InputReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class TaskD {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.readInt();
        int m = in.readInt();

        int[] c = IOUtils.readIntArray(in, n);
        int min_c = Integer.MAX_VALUE;
        int max_c = -1;
        for (int i = 0; i < n; ++i) {
            min_c = Math.min(min_c, c[i]);
            max_c = Math.max(max_c, c[i]);
        }

        HashSet<Integer> set[] = new HashSet[max_c + 1];
        for (int i = 0; i <= max_c; ++i)
            set[i] = new HashSet<Integer>();

        for (int i = 0; i < m; ++i) {
            int u = in.readInt() - 1;
            int v = in.readInt() - 1;
            if (c[u] != c[v]) {
                set[c[u]].add(c[v]);
                set[c[v]].add(c[u]);
            }
        }

        int ans = min_c;
        for (int i = min_c + 1; i <= max_c; ++i)
            if (set[ans].size() < set[i].size())
                ans = i;

        out.println(ans);
    }
}
